package dto

import (
	"time"
	"vrcm/src/vrcm/app/admin/models/live_schedule"
	"vrcm/src/vrcm/common/dto"
	common "vrcm/src/vrcm/common/models"
)

type SourceGroupGetPageReq struct {
	dto.Pagination `search:"-"`
	TenantId       string `json:"tenant_id" search:"type:exact;column:tenant_id;table:source_group"`
	GroupName      string `json:"group_name"  search:"type:contains;column:group_name;table:source_group"`
}

type SourceGroupOrder struct {
	Id         string `form:"idOrder"  search:"type:order;column:id;table:source_group"`
	GroupName  string `form:"group_nameOrder"  search:"type:order;column:group_name;table:source_group"`
	GroupDesc  string `form:"group_descOrder"  search:"type:order;column:group_desc;table:source_group"`
	IsDelete   string `form:"is_deleteOrder"  search:"type:order;column:is_delete;table:source_group"`
	CreateTime string `form:"create_timeOrder"  search:"type:order;column:create_time;table:source_group"`
	UpdateTime string `form:"update_timeOrder"  search:"type:order;column:update_time;table:source_group"`
	CreateBy   string `form:"createByOrder"  search:"type:order;column:create_by;table:source_group"`
	UpdateBy   string `form:"updateByOrder"  search:"type:order;column:update_by;table:source_group"`
}

func (m *SourceGroupGetPageReq) GetNeedSearch() interface{} {
	return *m
}

type SourceGroupInsertReq struct {
	TenantId  string `json:"tenant_id" comment:"租户" validate:"required"`
	GroupName string `json:"group_name" comment:"组名称" validate:"required,max=50"`
	GroupDesc string `json:"group_desc" comment:"组描述" validate:"max=500"`
	common.ControlBy
}

func (s *SourceGroupInsertReq) Generate(model *live_schedule.SourceGroup) {
	now := time.Now().Unix()
	model.TenantId = s.TenantId
	model.GroupName = s.GroupName
	model.GroupDesc = s.GroupDesc
	model.IsDelete = 2
	model.CreateTime = now
	model.UpdateTime = now
	model.CreateBy = s.CreateBy // 添加这而，需要记录是被谁创建的
}

func (s *SourceGroupInsertReq) GetId() interface{} {
	return ""
}

type SourceGroupUpdateReq struct {
	Id        int    `uri:"id" comment:""` //
	TenantId  string `json:"tenant_id" comment:"租户" validate:"required"`
	GroupName string `json:"group_name" comment:"组名称" validate:"required,max=50"`
	GroupDesc string `json:"group_desc" comment:"组描述" validate:"max=500"`
	common.ControlBy
}

func (s *SourceGroupUpdateReq) Generate(model *live_schedule.SourceGroup) {
	if s.Id == 0 {
		model.Model = common.Model{Id: s.Id}
	}

	now := time.Now().Unix()
	model.TenantId = s.TenantId
	model.GroupName = s.GroupName
	model.GroupDesc = s.GroupDesc
	model.IsDelete = 2
	model.UpdateTime = now
	model.UpdateBy = s.UpdateBy // 添加这而，需要记录是被谁更新的
}

func (s *SourceGroupUpdateReq) GetId() interface{} {
	return s.Id
}

// SourceGroupGetReq 功能获取请求参数
type SourceGroupGetReq struct {
	Id int `uri:"id"`
}

func (s *SourceGroupGetReq) GetId() interface{} {
	return s.Id
}

// SourceGroupDeleteReq 功能删除请求参数
type SourceGroupDeleteReq struct {
	Ids []int `json:"ids"`
}

func (s *SourceGroupDeleteReq) GetId() interface{} {
	return s.Ids
}

type SourceGroupRelationReq struct {
	TenantId  string `json:"tenant_id" comment:"租户" validate:"required"`
	GroupId   int    `json:"group_id" comment:"组id" validate:"required"`
	SourceIds []int  `json:"source_ids" comment:"信源id"`
	common.ControlBy
}

type SourceGetDetailReq struct {
	Id         int            `json:"id"`
	TenantId   string         `json:"tenant_id" comment:"租户" validate:"required"`
	Pagination dto.Pagination `json:"pagination"`
}
